# $Id: PKGBUILD 178694 2013-02-26 10:20:09Z guillaume $
# Maintainer: Guillaume ALAUX <guillaume@archlinux.org>
pkgname=swt
pkgver=4.2.1
pkgrel=2
_date=201209141800
pkgdesc='An open source widget toolkit for Java'
arch=('i686' 'x86_64')
url='http://www.eclipse.org/swt/'
license=('EPL')
depends=('java-runtime>=6' 'gtk2>=2.20.1' 'libxtst')
optdepends=('libgnomeui' 'mesa' 'glu' 'libwebkit')
makedepends=('java-environment' 'libxtst' 'mesa' 'glu' 'libgnomeui' 'unzip' 'pkgconfig' 'libwebkit' 'apache-ant')
if [ "${CARCH}" = "i686" ]; then
  _carch=x86
  sha256sums=('6198cd749ec25303a8c3a044e7680d643209862d2947f9efdda20bf7467575ba'
              '6bb48007a95e3d8c6b577cc9cc4b61a51ce928b04f4fcd393cf72f8f727fe923')
fi
if [ "${CARCH}" = "x86_64" ]; then
  _carch=x86_64
  sha256sums=('e89e330df24ca72c57a381e81590293ce3f475d855258183179436bd5dcd85c8'
              '6bb48007a95e3d8c6b577cc9cc4b61a51ce928b04f4fcd393cf72f8f727fe923')
fi
source=(http://download.eclipse.org/eclipse/downloads/drops4/R-${pkgver}-${_date}/swt-${pkgver}-gtk-linux-${_carch}.zip
        build-swt.xml)
# To test this pkg:
# http://www.eclipse.org/swt/examples.php#standaloneOutsideEclipse
# http://download.eclipse.org/eclipse/downloads/

build() {
  cd ${srcdir}
  unzip -oq src.zip -d src

  . /etc/profile.d/jdk.sh
  . /etc/profile.d/apache-ant.sh

  # Shared objects
  cd src
  ./build.sh

  # SWT jar
  ant -f ../build-swt.xml compile
}

package() {
  cd ${srcdir}/src

  # Shared objects
  export OUTPUT_DIR=${pkgdir}/usr/lib
  install -dm755 ${OUTPUT_DIR} 
  make -f make_linux.mak install

  # SWT jar
  ant -f ../build-swt.xml jar
  install -Dm755 ../swt.jar ${pkgdir}/usr/share/java/swt-${pkgver}.jar
  ln -s swt-${pkgver}.jar ${pkgdir}/usr/share/java/swt.jar
}
